import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
import Confirm from 'vux/src/components/confirm/index.vue';
import util from '@/common/util.js';

export default {
  name: 'qd_list_seq',
  components: {Confirm},
  data () {
    return {
      siteId: '',
      // 班级id
      classId: '',
      studentId: '',
      studentName: '',
      content: {},
      isDisabled:false,
      signClass:'signUpBtn',
      agree: true,
      show: false
    }
  },
  mounted () {
    this.$router.afterEach((to, from, next) => {
      window.scrollTo(0, 0);
    });
    var _this = this
    var studertids = ''
    _this.siteId = window.sessionStorage.getItem('siteId')
    _this.studentId = window.sessionStorage.getItem('studentId')
    _this.classId = this.$route.query.classId
    studertids = _this.studentId
    if (studertids == '-1') {
      studertids = ''
    }
    _this.loadList()
  },
  methods: {
    loadList() {
      let _this = this
      http.post(CONSTANT.SIGNCLASSSCHEDULE, {
        clazzId: _this.classId
      }, (res) => {
        _this.content = res
      for (var i = 0;i < res.length;i++) {
        let dateStr = util.dateFormat(res[i].beginTime,true)
        let enddateStr = util.dateFormat(res[i].endTime,true)
        _this.content[i].beginTime = dateStr.substring(0,10)
        _this.content[i].endTime = dateStr.substring(11,16) + '到' + enddateStr.substring(11,16)
        _this.content[i].signIn.signNum = res[i].signIn.signNum + '/' + res[i].signIn.totalNum
        if (_this.content[i].teachSign == '0') {
          _this.content[i].teachSignStr = '<font color = "#2f82ff">签到</font>'
        } else if (_this.content[i].teachSign == '2') {
          _this.content[i].teachSignStr = '<font>已请假</font>'
        } else {
          _this.content[i].teachSignStr = '<font>已签到</font>'
        }
      }
      })
    },
    comeBack () {
      window.history.go(-1)
    },
    qd(seq,status) {
        let _this = this
        if (status == 0) {
          http.post(CONSTANT.TEACHERSIGN, {
            clazzId: _this.classId,
            seq: seq,
            userId: _this.studentId,
            status: 1,
            orgId: _this.siteId
          }, (res) => {
            alert(JSON.stringify(res))
            _this.loadList()
          })
        }
    }
  }
}
